package cn.lili.modules.member.entity.dos;

import cn.lili.common.utils.BeanUtil;
import cn.lili.common.utils.SnowFlake;
import cn.lili.modules.member.entity.dto.UnionMemberApplyDTO;
import cn.lili.mybatis.model.BaseSceneEntity;
import cn.lili.mybatis.model.BaseStandardEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

@EqualsAndHashCode(callSuper = true)
@Data
@TableName("li_union_member")
@ApiModel(value = "工会成员")
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class UnionMember extends BaseStandardEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "工会ID")
    private String unionId;

    @ApiModelProperty(value = "工会成员ID")
    private String memberId;

    @ApiModelProperty(value = "工会成员名称")
    private String memberName;

    @ApiModelProperty(value = "工会成员头像")
    private String memberHead;

    @ApiModelProperty(value = "加入工会时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date joinTime;

    @ApiModelProperty(value = "加入工会状态,UnionMemberStatusEnum类型")
    private String status;

    @ApiModelProperty(value = "操作类型,UnionMemberOptypeEnum类型")
    private String optype;

    @ApiModelProperty(value = "申请退出次数")
    private Integer quitTimes;

    @ApiModelProperty(value = "所在城市")
    private String city;

    @ApiModelProperty(value = "本月业绩")
    @TableField(exist = false)
    private Double monthMoney = 0D;

    @ApiModelProperty(value = "上月业绩")
    @TableField(exist = false)
    private Double lastMonthMoney = 0D;

    @ApiModelProperty(value = "本月业绩-最低")
    @TableField(exist = false)
    private Double startMoney;

    @ApiModelProperty(value = "本月业绩-最高")
    @TableField(exist = false)
    private Double endMoney;

    @ApiModelProperty(value = "下级人数")
    @TableField(exist = false)
    private Integer childCount = 0;

    @ApiModelProperty(value = "飞语账号")
    @TableField(exist = false)
    private String fyAccount;


    public UnionMember(UnionMemberApplyDTO unionMemberDTO) {
        BeanUtil.copyProperties(unionMemberDTO, this);
        this.setId(SnowFlake.getIdStr());
    }
}
